package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbTypeTemplateMapper;
import com.dongdongshop.pojo.TbTypeTemplate;
import com.dongdongshop.service.TypeTemplateService;
import com.dongdongsop.data.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@DubboService
public class TypeTemplateServiceImpl implements TypeTemplateService {

    @Resource
    private TbTypeTemplateMapper typeTemplateMapper;

    @Override
    public PageResult<TbTypeTemplate> typeTemplateInfo(Integer pageNumber, Integer pageSize) {
        PageHelper.startPage(pageNumber,pageSize);
        List<TbTypeTemplate> typeTemplateList = typeTemplateMapper.selectByExample(null);
        PageInfo info = new PageInfo(typeTemplateList);
        return new PageResult<>(info.getTotal(),info.getList());
    }

    @Override
    public int typeTemplateAdd(TbTypeTemplate typeTemplate) {
        return typeTemplateMapper.insertSelective(typeTemplate);
    }

    @Override
    public TbTypeTemplate getTypeTemplateByBrandAllBySpecAll(Long id) {
        return typeTemplateMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateTypeTemplate(TbTypeTemplate typeTemplate) {
        return typeTemplateMapper.updateByPrimaryKeySelective(typeTemplate);
    }

    @Override
    public int deleteId(Long id) {
        return typeTemplateMapper.deleteByPrimaryKey(id);
    }
}
